﻿SortedSet<Int32> set = new SortedSet<Int32>();

for (int i = 1; i <= 100 ; i++)
{
    set.Add(i);
}

for (int i = 2; i <= 100; i++)
{
    Int32 temp;
    if (set.TryGetValue(i, out temp))
    {
        for (Int32 k = temp * 2; k <= 100; k += temp)
        {
            set.Remove(k);
        }
    }
}

foreach (Int32 i in set)
{
    Console.Write(i+",");
}
